package com.lc.user.express.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lc.user.express.R;
import com.lc.user.express.app.AppContext;
import com.lc.user.express.model.MyStardandModel;

import java.util.List;


/**
 * Created by Administrator on 2016/4/1.
 */
public class StardandAdapter extends BaseListAdapter<MyStardandModel> {
    public StardandAdapter(Context context, List<MyStardandModel> data) {
        super(context, data);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        MyStardandModel myStardandModel = data.get(position);
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_list_stardand, null);
            AppContext.ScaleScreenHelper.loadView((ViewGroup) convertView);
            viewHolder = new ViewHolder();
            viewHolder.tv1_stardand_item = (TextView) convertView.findViewById(R.id.tv1_stardand_item);
            viewHolder.tv2_stardand_item = (TextView) convertView.findViewById(R.id.tv2_tardand_item);
            viewHolder.tv3_stardand_item = (TextView) convertView.findViewById(R.id.tv3_stardand_item);
            convertView.setTag(viewHolder);

        }
        setContextView(convertView, myStardandModel);
        return convertView;
    }

    private void setContextView(View convertView, MyStardandModel myStardandModel) {
        ViewHolder viewHolder = (ViewHolder) convertView.getTag();
        viewHolder.tv1_stardand_item.setText(myStardandModel.getTv1_stardand_item());
        viewHolder.tv2_stardand_item.setText(myStardandModel.getTv2_stardand_item() + "元/5公里");
        viewHolder.tv3_stardand_item.setText(myStardandModel.getTv3_stardand_item() + "元/公里");
    }

    public class ViewHolder {
        TextView tv1_stardand_item;
        TextView tv2_stardand_item;
        TextView tv3_stardand_item;
    }
}
